<?php
    include "../lib/DAL/DmtrangthaidtDAL.php";

    class DmtrangthaidtBLL
    {
        function __construct()
    	{
    	}
    	function __destruct()
    	{
    	}
        public function getListtrangthai()
        {
            $sql = "select * from dm_trangthai_diemthi";
            $result= mysql_query($sql) or die(mysql_error());
            $arr_trangthai= array();
            while($row = mysql_fetch_array($result))
            {
                $arr_trangthai[]= $this->settrangthaiBLL($row);
            } 
            return $arr_trangthai;
        }
        public function inserttrangthai($trangthai)
        {
            $sql ="INSERT INTO dm_trangthai_diemthi(madm_tt_diemthi,ten_tt_diemthi)
                                            VALUES ('".$trangthai->getmatrangthai()."',
                                            '".$trangthai->gettentrangthai()."'
                                            )";
            $result = mysql_query($sql) or die (mysql_error());
            return $result;
        }
        public function updatetrangthai($trangthai){
            $sql="UPDATE dm_trangthai_diemthi
                SET ten_tt_diemthi='".$trangthai->gettentrangthai()."' 
                WHERE madm_tt_diemthi='".$trangthai->getmatrangthai()."'";
            $result = mysql_query($sql) or die (mysql_error());
            return $result;
        }
        public function deletetrangthai($trangthai){
            $sql= "DELETE FROM `dm_trangthai_diemthi` WHERE `madm_tt_diemthi`='".$trangthai."'";
    
            $result = mysql_query($sql) or die (mysql_errno());
            return $result;    
        }
        public function settrangthaiBLL($row){
            $dm_trangthai= new DmtrangthaidtDAL();
            $dm_trangthai->setdmtrangthai($row['madm_tt_diemthi'],$row['ten_tt_diemthi']);
            return $dm_trangthai;
        }
}
?>